dom: report the DOMXPath callback node list to the cycle collector - #23596
Open
iliaal wants to merge 1 commit into
Open
dom: report the DOMXPath callback node list to the cycle collector#23596iliaal wants to merge 1 commit into
iliaal wants to merge 1 commit into
Conversation
php_dom_xpath_callbacks_get_gc() traced php_ns and namespaces but not node_list, which holds the nodes handed to and returned from php:function callbacks. A cycle running DOMXPath to node_list to node and back to the same DOMXPath was therefore invisible to the collector and never freed. Closes phpGH-23596
iliaal
force-pushed
the
promote/dom-xpath-node-list-gc
branch
from
September 6, 2026 15:08
472bca6 to
95b6eb9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
php_dom_xpath_callbacks_get_gc()tracedphp_nsandnamespacesbut notnode_list, which holds the nodes passed to and returned fromphp:functioncallbacks. A cycle from aDOMXPaththrough node_list to a node and back to the same DOMXPath was invisible to the collector, so it was never freed.node_list is still cleared at object destruction rather than at the end of each evaluation. Clearing it eagerly is not safe, because a callback can run a nested
query()/evaluate()on the same object and the inner call would free wrappers the outer evaluation is still using.